/*
 *****************************************************************************
 * Copyright (C) 2005-2014 UC Mobile Limited. All Rights Reserved
 * File			: UCYouaiViewController.m
 *
 * Description	: UCYouaiViewController
 *
 * Author		: mac000@ucweb.com
 *
 * History		: Creation, 14/11/15, mac000@ucweb.com, Create the file
 ******************************************************************************
 **/

#import <UIKit/UIKit.h>
#import <Foundation/Foundation.h>

#import "UCYouaiViewController.h"

#import "PackageItemList.h"
#import "HUWebViewController.h"
#import "StockViewController.h"
#import "ProxyDetectWapper.h"


@interface UCYouaiViewController ()

@end

@implementation UCYouaiViewController


- (void)viewDidLoad {
    
    [super viewDidLoad];
    
    //[self detectWifiMode];
    
    self.title = @"UC Test Demo";
    self.view.backgroundColor = [UIColor whiteColor];
    
    CGRect navigationRect = self.navigationController.view.frame;
    CGFloat relativeHeight = self.view.frame.size.height - navigationRect.origin.y - 20;
    
    CGColorSpaceRef colorSpace = CGColorSpaceCreateDeviceRGB();
    CGColorRef colorref = CGColorCreate(colorSpace,(CGFloat[]){ 0, 0, 1, 1 });
    
    CGColorSpaceRelease(colorSpace);
    
    UIButton *enterPackViewBtn = [UIButton buttonWithType:UIButtonTypeSystem];
    [enterPackViewBtn setFrame:CGRectMake(110,relativeHeight * 0.3,100,30)];
    enterPackViewBtn.titleLabel.font = [UIFont systemFontOfSize:12];
    
    [enterPackViewBtn.layer setMasksToBounds:YES];
    [enterPackViewBtn.layer setCornerRadius:4.0];
    [enterPackViewBtn.layer setBorderWidth:1.0];
  
    [enterPackViewBtn.layer setBorderColor:colorref];
    
    [enterPackViewBtn setTitle:@"Enter PackView" forState:UIControlStateNormal];
    [enterPackViewBtn addTarget:self action:@selector(enterPackItemView:) forControlEvents:UIControlEventTouchUpInside];
    [self.view addSubview:enterPackViewBtn];
    
    UIButton *enterWebViewBtn = [UIButton buttonWithType:UIButtonTypeSystem];
    [enterWebViewBtn setFrame:CGRectMake(110,relativeHeight * 0.5,100,30)];
    enterWebViewBtn.titleLabel.font = [UIFont systemFontOfSize:12];
    
    [enterWebViewBtn.layer setMasksToBounds:YES];
    [enterWebViewBtn.layer setCornerRadius:4.0];
    [enterWebViewBtn.layer setBorderWidth:1.0];
    [enterWebViewBtn.layer setBorderColor:colorref];
    
    [enterWebViewBtn setTitle:@"Enter WebView" forState:UIControlStateNormal];
    [enterWebViewBtn addTarget:self action:@selector(enterWebView:) forControlEvents:UIControlEventTouchUpInside];
    [self.view addSubview:enterWebViewBtn];
    
    UIButton *enterAutoViewBtn = [UIButton buttonWithType:UIButtonTypeSystem];
    [enterAutoViewBtn setFrame:CGRectMake(110,relativeHeight * 0.7,100,30)];
    enterAutoViewBtn.titleLabel.font = [UIFont systemFontOfSize:12];
    
    [enterAutoViewBtn.layer setMasksToBounds:YES];
    [enterAutoViewBtn.layer setCornerRadius:4.0];
    [enterAutoViewBtn.layer setBorderWidth:1.0];
    [enterWebViewBtn.layer setBorderColor:colorref];
    
    [enterAutoViewBtn setTitle:@"Enter AutoView" forState:UIControlStateNormal];
    [enterAutoViewBtn addTarget:self action:@selector(enterAutoView:) forControlEvents:UIControlEventTouchUpInside];
    
    CGColorRelease(colorref);
    
    [self.view addSubview:enterAutoViewBtn];
    
    //[self enterWebView];

}

-(void)detectWifiMode
{
    ProxyDetectWapper *_proxyDetect = [[ProxyDetectWapper alloc] init];
    NSLog(@"isUseProxy: %d",[_proxyDetect hasUseProxySetting]);
    [_proxyDetect release];
}

//-(void)enterWebView
//{
//
//    HUWebViewController* _webView = [[[HUWebViewController alloc] init] autorelease];
//    
//    [self.navigationController pushViewController:_webView animated:YES];
//    //[self presentViewController:_webView animated:YES completion:nil];
//    
//}

-(void)enterWebView:(id)sender
{
    HUWebViewController* _webView = [[[HUWebViewController alloc] init] autorelease];
    
    [self.navigationController pushViewController:_webView animated:YES];
}

-(void)enterAutoView:(id)sender
{
    StockViewController* stockView = [[[StockViewController alloc] init] autorelease];
    [self.navigationController pushViewController:stockView animated:YES];
}

-(void)enterPackItemView:(id)sender
{
    PackageItemList *packItemList = [[[PackageItemList alloc] init] autorelease];
    [packItemList.view setFrame:CGRectMake(0.0f,self.view.frame.origin.y+ 60.0f , self.view.frame.size.width, self.view.frame.size.height)];
    
    [self.navigationController pushViewController:packItemList animated:YES];
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

-(void)dealloc
{
    [super dealloc];
}


@end
